//
//  MyBillsTableViewCell.m
//  HTP
//
//  Created by 王鑫 on 15/11/1.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "MyBillsTableViewCell.h"

@interface MyBillsTableViewCell ()

@property (nonatomic,retain) UIImageView *icoImage;

@property (nonatomic,retain) UILabel *infolabel;

@property (nonatomic,retain) UILabel *infoTimeLabel;

@property (nonatomic,retain) UILabel *moneyLabel;

@property (nonatomic,retain) NSDictionary *cellDic;

@property (nonatomic,retain) UIImageView *line1;

@property (nonatomic,retain) UIImageView *line2;

@end

@implementation MyBillsTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self _initUI];
    }
    return self;
}

//TODO:控件添加
- (void)_initUI {
    
    self.contentView.backgroundColor = [UIColor colorWithRed:243 / 255.0 green:243 / 255.0 blue:243 / 255.0 alpha:0.6];
    
    _icoImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_icoImage];
    
    _infolabel = [[UILabel alloc] init];
    _infolabel.font = [UIFont systemFontOfSize:18.0f];
    [self.contentView addSubview:_infolabel];
    
    _infoTimeLabel = [[UILabel alloc] init];
    _infoTimeLabel.textColor = [UIColor colorWithRed:147 / 255.0 green:147 / 255.0 blue:147 /255.0 alpha:0.6];
    _infoTimeLabel.font = [UIFont systemFontOfSize:12.0f];
    [self.contentView addSubview:_infoTimeLabel];
    
    _moneyLabel = [[UILabel alloc] init];
    _moneyLabel.font = [UIFont systemFontOfSize:12.0f];
    [self.contentView addSubview:_moneyLabel];
    
    _line1 = [[UIImageView alloc] init];
    [_line1 setAlpha:0.4];
    [self.contentView addSubview:_line1];
    
    _line2 = [[UIImageView alloc] init];
    [_line2 setAlpha:0.4];
    [self.contentView addSubview:_line2];
    
}

//TODO:控件位置设置
- (void)layoutSubviews {
    [_icoImage setFrame:CGRectMake(22, 10, 30, 40)];
    
    [_infolabel setFrame:CGRectMake(74, 20, 100, 20)];
    
    [_infoTimeLabel setFrame:CGRectMake(ScreenWidth - 76, 10, 80, 20)];
    
    [_moneyLabel setFrame:CGRectMake(ScreenWidth - 60, 35, 50, 20)];
    
    [_line1 setFrame:CGRectMake(0, 60, ScreenWidth, 1)];
    [_line2 setFrame:CGRectMake(0, 0, ScreenWidth, 1)];
}

//TODO:控件数据设置
- (void)setCellData:(id)cellData {
    _cellDic = (NSDictionary *)cellData;
    
    _icoImage.image = [UIImage imageNamed:_cellDic[@"icoUrl"]];
    
    _infolabel.text = _cellDic[@"info"];
    
    _infoTimeLabel.text = _cellDic[@"time"];
    
    if ([_cellDic[@"icoUrl"] isEqualToString:@"zhichu"]) {
        _moneyLabel.textColor = [UIColor orangeColor];
    }else
        _moneyLabel.textColor = [UIColor greenColor];
    
    _moneyLabel.text = _cellDic[@"money"];
    
    _line1.image = [UIImage imageNamed:@"line_zhangdan"];
    _line2.image = [UIImage imageNamed:@"line_zhangdan"];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
